<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Account Creation</title>
<style type="text/css">
<!--
body {
background-color: #000000;
background-image: url(../images/alliance-tile.jpg); background-repeat:repeat-x;
}
body,td,th {
color: #CC9900;
font-family: Arial, Helvetica, sans-serif;
font-size: 13px;
}
a:link {
color:#CC9900; 

}
a:visited {
color:#CC9900;

}
a:hover {
color:#ffffff;
}
a:active {
color:#FF0000;


}
input { background:transparent; background-image:url(../images/transp.png); color:#FFFFFF; border: 1px solid #333333}
select { background-color:#000000; color:#FFFFFF; border: 1px solid #333333}
textarea { background-color:#000000; color:#FFFFFF; border: 1px solid #333333}

-->
</style>
</head>
<body>
<?php
if(isset($_POST['submit']))
{
	$bademail = 0;
	$email = $_POST['email'];
	$email = strip_tags($email);
	$email = trim($email);
	$getbademails = "SELECT * from b_banemails";
	$getbademails2 = mysql_query($getbademails, $forum) or die("Error #1:" . mysql_error());
	while($getbademails3 = mysql_fetch_array($getbademails2))
	{
		if(substr_count($email, $getbademails3['email']) > 0)
		{
			$bademail++;
		}
	}
	if($bademail>0)
	{
		die("<br><br><br><br><table border='0' cellpadding='3' cellspacing='3' align='center' style='border: 1px solid #000000; background-image: url(../images/transp.png)'><tr><td style='background-image: url(../images/transpblack.png)'><center><font style='color: #FF0000'><strong>Error</strong></font></center></td></tr><tr><td><center>That email is banned from registering</center></td></tr></table>");
	}
	$valid = 1;
	$username = $_POST['username'];
	$username = strip_tags($username);
	$username = trim($username);
	$password = $_POST['password'];
	$password = trim($password);
	$signature = $_POST['signature'];
	$signature = trim($signature);
	$pass2 = $_POST['pass2'];
	$usercheck = "SELECT * FROM b_users WHERE username='$username' OR email='$email'";
	$usercheck2 = mysql_query($usercheck, $forum) or die("Error #2:" . mysql_error());
	while ($usercheck3 = mysql_fetch_array($usercheck2))
	{
		$valid = 0;
	}
	if($valid==0)
	{
		print "<br><br><br><br><table border='0' cellpadding='3' cellspacing='3' align='center' style='border: 1px solid #000000; background-image: url(../images/transp.png)'>";
		print "<tr><td style='background-image: url(../images/transpblack.png)'><center><font style='color: #FF0000'><strong>Error</strong></font></center></td></tr>";
		print "<tr><td><center>";  
		print "That username has been taken or there is already someone registered with that email or you did not enter email,<br> please <A href='register.php'>try to register again</a>. (or hit back)";
		print "</td></tr></table></center>";
	}
	else if(substr_count($username, " ")>0)
	{
		die("Spaces are not allowed in names");
	}
	else if(!preg_match("^[A-Za-z0-9]+$^", "$username"))
	{
		print "There were invalid characters in the username.";
	}   
	else if(strlen($username)>15 || strlen($username)<3)
	{
		print "<br><br><br><br><table border='0' cellpadding='3' cellspacing='3' align='center' style='border: 1px solid #000000; background-image: url(../images/transp.png)'>";
		print "<tr><td style='background-image: url(../images/transpblack.png)'><center><font style='color: #FF0000'><strong>Error</strong></font></center></td></tr>";
		print "<tr><td><center>";  
		die("Username must be between 3 and 15 characters in length");
		print "</center></td></tr></table>";
	}
	else if(strlen($email)<4 || substr_count($email," ")>0)
	{
		die("<br><br><br><br><table border='0' cellpadding='3' cellspacing='3' align='center' style='border: 1px solid #000000; background-image: url(../images/transp.png)'><tr><td style='background-image: url(../images/transpblack.png)'><center><font style='color: #FF0000'><strong>Error</strong></font></center></td></tr><tr><td>You did not enter an email or email has not valid format.</center></td></tr></table>"); 
	}
	else
	{
		if ($password == $pass2 && $_POST['password'])
		{
			$password2 = md5($password);
			$supervalue = $value;
			$day = date("U");
			$email = $_POST['email'];
			$location = $_POST['location'];
			$aim = $_POST['aim'];
			$showprofile = $_POST['showprofile'];
			$icq = $_POST['icq'];
			$seedval = $day%100000;
			srand($seedval);
			$key = RAND(1000000,2000000);
			if($requirekey == "no" || $requirekey == "No")
			{
				$SQL = "INSERT into b_users (username,password,email,validated,location,AIM,ICQ,showprofile) values('$username','$password2','$email','1','$location','$aim','$icq','$showprofile')";
				mysql_query($SQL, $forum) or die("Error #3:" . mysql_error());
				
				$SQLwow = "INSERT into accounts (login,password,gm,banned,lastip,email,flags,forceLanguage) values ('$username','$pass2','','0','".$_SERVER['REMOTE_ADDR']."','$email','8','enUS')";
				mysql_query($SQLwow, $logon) or die("Error #4:" . mysql_error());
		}
		else //you require an activation key
		{
			$SQL = "INSERT into b_users (username,password,sig, keynode,email,location,AIM,ICQ,showprofile) values('$username','$password2','$signature','$key','$email','$location','$aim','$icq','$showprofile')";
			mysql_query($SQL, $forum) or die("Error #5:" . mysql_error());
			
			$SQLwow = "INSERT into accounts (login,password,gm,banned,lastip,email,flags,forceLanguage) values ('$username','$pass2','','0','".$_SERVER['REMOTE_ADDR']."','$email','8','enUS')";
			mysql_query($SQLwow, $logon) or die("Error #6:" . mysql_error());
			
			mail($email, "Your forum activation key","Paste the URL to activate your account. ".$boardpath."activate.php?username=$username&password=$password&keynode=$key");
		} 
		print "<br><br><br><br><table border='0' cellpadding='3' cellspacing='3' align='center' style='border: 1px solid #000000; background-image: url(../images/transp.png)'>";
		print "<tr><td style='background-image: url(../images/transpblack.png)'><center><strong><font style='color: #00CC00'>Success! Way to go!</font></strong></center></td></tr>";
		print "<tr><td>";
		if($requirekey == "no" || $requirekey == "No")
		{
			print "<center>Forum and Server account are created!<br>You can now login to server with your username and password.<br><br>You mast wait 10 mins until server account become active.<br><br><strong><font color='white'>set realmlist ecimo.tv</font></strong></center><br><br>";
			print "";
			print "<tr><td style='background-image: url(../images/transp.png)'><center>Your username is $username.<br>Your password is $pass2.</center></td></tr>";
			print "<tr><td style='background-image: url(../images/transpblack.png)'><center><a href='login.php'>Click here to Login</a></center></td></tr>";
		}
		else
		{
			print "Forum registration completed please check your email for activation key. Go <a href='login.php'>here to Login</a>.";
		}
		if($notifyme == "Yes" || $notifyme == "yes")
		{
			mail($adminemail, "Registration at $sitetitle forums", "This is just to inform you that $username has just registered in your forums");
		}
		print "</td></tr></table>";
	}
	else
	{
		print "<br><br><br><br><table border='0' cellpadding='3' cellspacing='3' align='center' style='border: 1px solid #000000; background-image: url(../images/transp.png)'>";
		print "<tr><td style='background-image: url(../images/transpblack.png)'><center><font style='color: #FF0000'><strong>Error</strong></font></center></td></tr>";
		print "<tr><td><center>"; 
		print "Your passwords didn't match or you did not enter a password";
		print "</center></td></tr></table>";
		}
	}
}
?>
</body>
</html>

